const config = {
	/**
	 * 服务器配置
	 */
	baseUrl: 'http://47.120.1.177/emsapi/', //测试
	// baseUrl: 'https://tmctest.careland.com.cn/ems/', //临时
	// baseUrl: 'https://tmctest.careland.com.cn/', //正式
	// baseUrl: 'https://tmctest.careland.com.cn/ems/', //测试

	// request get 请求
	getData: (url, param) => {
		return new Promise((resolve, reject) => {
			uni.showLoading({
				mask: true
			});
			uni.request({
				url: url,
				method: 'GET',
				data: param,
				header: {
					'content-type': 'application/x-www-form-urlencoded'
				},
				success(res) {
					uni.hideLoading();
					resolve({
						code: 0,
						json: res
					})
				},
				fail(res) {
					uni.hideLoading();
					resolve({
						code: 1,
						json: res
					})
				}
			})
		})
	},

	// request post 请求
	postData: (url, param) => {
		return new Promise((resolve, reject) => {
			uni.showLoading();
			uni.request({
				url: url,
				method: 'POST',
				data: param,
				header: {
					'content-type': 'application/x-www-form-urlencoded'
				},
				success(res) {
					uni.hideLoading();
					resolve({
						code: 0,
						json: res
					})
				},
				fail(res) {
					uni.hideLoading();
					resolve({
						code: 1,
						json: res
					})
				}
			})
		})
	},

	//sleep停留时间
	sleep: (milSec) => {
		return new Promise(resolve => {
			setTimeout(resolve, milSec);
		})
	},
}



module.exports = config